package momo.app.structure;

public class Link<T, V>
{
	static final int FIRST = 1;
	static final int SECOND = 2;
	
	private Object elemT;
	private Object elemV;
	
	public Link(T objT, V objV)
	{
		elemT = objT;
		elemV = objV;
	}
	
	public synchronized boolean contains(Object o)
	{
		if ( elemT.equals(o) )
			return true;
		if ( elemV.equals(o) )
			return true;
		return false;
	}
	
	public synchronized void setFirst(T objT)
	{
		elemT = objT;
	}
	
	public synchronized void setSecond(V objV)
	{
		elemV = objV;
	}
	
	public synchronized T getFirst()
	{
		return (T)get(1);
	}
	
	public synchronized V getSecond()
	{
		return (V)get(2);
	}
	
	public synchronized Object get(int index)
	{
		if ( index == 1 )
			return elemT;
		else if ( index == 2 )
			return elemV;
		return null;
	}
}//end of class Link<T, V>
